package Work;

import java.util.ArrayList;

class Fruit{
	private String name;
	public Fruit(String name){
		this.name = name;
		
	}
	@Override
	public String toString() {
		return super.toString()+"-"+"Fruit [name=" + name + "]"+"\n";
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Fruit other = (Fruit) obj;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equalsIgnoreCase(other.name))
			return false;
		return true;
	}
	
}

public class Fruits {

	public static void main(String[] args){
		ArrayList<Fruit> fList = new ArrayList<Fruit>();
		Fruit[] f = new Fruit[6];
		f[0] = new Fruit("Peach");
		f[1] = new Fruit("apple");
		f[2] = new Fruit("Banana");
		f[3] = new Fruit("Apple");
		f[4] = new Fruit("banana");
		f[5] = new Fruit("Orange");
		for (int i = 0; i < f.length; i++) {
			if(!fList.contains(f[i])){
				fList.add(f[i]);
			}
		}
		System.out.println(fList);
		
	}
}
